package com.tangzx

import org.gradle.util.ConfigureUtil

/**
 * @author Administrator
 * Created: Tue Jun 23 17:25:12 CST 2015
 */
class SWFConfusionPluginConvention {
    ArrayList<SWFInput> allExcludeLibList = new ArrayList<SWFInput>();

    ArrayList<SWFInput> allSwf = new ArrayList<SWFInput>();

    File logFile

    File keyWord

    File mixWord

    void logFile(Object o) {
        if (o instanceof String) {
            this.logFile = new File(o)
        } else if (o instanceof File) {
            this.logFile = o
        }
    }

    void addSWF(Object o) {
        SWFInput swf = new SWFInput()
        if (o instanceof Closure) {
            ConfigureUtil.configure(o, swf)
        } else if (o instanceof File) {
            swf.input = o
            swf.output = o
        } else if (o instanceof String) {
            swf.input = new File(o)
            swf.output = new File(o)
        }

        allSwf.add(swf)
    }

    void addLib(Object o) {
        SWFInput swf = new SWFInput()
        if (o instanceof Closure) {
            ConfigureUtil.configure(o, swf)
        } else if (o instanceof File) {
            swf.input = o
            swf.output = o
        } else if (o instanceof String) {
            swf.input = new File(o)
            swf.output = new File(o)
        }

        allExcludeLibList.add(swf)
    }

    void keyWord(Object o) {
        if (o instanceof File)
            keyWord = o
        else if (o instanceof String)
            keyWord = new File(o)
    }

    void mixWord(Object o) {
        if (o instanceof File)
            mixWord = o
        else if (o instanceof String)
            mixWord = new File(o)
    }
}

class SWFInput {
    File input
    File output

    void input(Object o) {
        if (o instanceof String) {
            this.input = new File(o)
        } else if (o instanceof File) {
            this.input = o
        }
    }

    void output(Object o) {
        if (o instanceof String) {
            this.output = new File(o)
        } else if (o instanceof File) {
            this.output = o
        }
    }
}